<include file="../Public/header" />

	
	<link href="__PUBLIC__/js/pagination/pagination.css" rel="stylesheet" type="text/css" />
	
	<script type="text/javascript" src="__PUBLIC__/js/jquery.form.js"></script>
	<script type="text/javascript">
		var ctrl = function(name){
			this.elements = document.getElementsByName('id[]');
			this.length = this.elements.length;
		}
		ctrl.prototype = {
			reverse:function(){
				for(i=0;i<this.length;i++){
					this.elements[i].checked= !this.elements[i].checked;
				}
			},
			all:function(){
				for(i=0;i<this.length;i++){
					this.elements[i].checked = true;
				}
			},
			unAll:function(){
				for(i=0;i<this.length;i++){
					this.elements[i].checked = false;
				}
			},
			toggle:function(obj){
				this[obj.checked ? 'all' : 'unAll']();
			},
			del:function(id){
				if(id==undefined){
					id = [];
					for(i=0;i<this.length;i++){
						this.elements[i].checked && id.push(this.elements[i].value);
					}
					id = id.join(',');
				}
				alert('您选择了id为:'+id);
			},
			edit:function(uid){
				location.href = "{:U('admin/User/edit')}&uid="+uid;
			},
			commend:function(id,type){
				location.href = "__URL__/commend/id/"+id+"/type/"+type;
			}
		}
		var c = null;
	</script>
	</head>
	<body>
	<div id="container">
    <table class="tableborder" width="100%">
    	<form method="POST" action="{:U('admin/User/index')}" autocomplete="off">
          <tbody>
            <tr class="top">
              <td class="border" colspan="2"></td>
            </tr>
            <tr>
              <th class="header" colspan="2">查询</th>
            </tr>
            <tr class="label">
              <th>说明</th>
              <th>条件</th>
            </tr>
            
            <tr class="cell">
              <td class="altbg1">
                <b>用户姓名名:</b>
                <br/>
                <span class="smalltxt">根据用户名查询</span>
              </td>
              <td class="altbg2"><input name="fullname" class="txt" value="{$fullname}"/></td>
            </tr>
		
            <tr class="cell">
              <td class="altbg1">
                <b>用户Id</b>
                <br/>
                <span class="smalltxt">根据用户id</span>
              </td>
              <td class="altbg2"><input name="searchuid" class="txt" value="{$searchuid}"/> 多个用户用逗号隔开</td>
            </tr>
            
            <tr class="cell">
              <td class="altbg1">
                <b>email</b>
                <br/>
                <span class="smalltxt">根据用户工号</span>
              </td>
              <td class="altbg2"><input name="uname" class="txt" value="{$uname}"/> </td>
            </tr>            
            
            <tr class="cell">
              <td class="altbg1">
                <b>用户组</b>
                <br/>
                <span class="smalltxt">用户所在组</span>
              </td>
              <td class="altbg2">
               	<select name="groupid">
              		<option value="9" <eq name="groupid" value="9">selected</eq> >全部</option>
					<volist id="vo" name="grouplist">				  
					 <php>if($vo['id']==$groupid){</php>
					 	<option value="{$vo.gid}" selected>{$vo.gname}</option>					 
					 <php>}else{</php>
						<option value="{$vo.gid}" >{$vo.gname}</option>
					 <php>}</php>
					</volist>
              	</select>             
              </td>
            </tr>            
      

            <tr class="cell">
              <td class="altbg1">
                <b>结果排序</b>
                <br/>
              </td>
              <td class="altbg2">

                <select name="limit">
                  <option value = "10" <eq name="limit" value="10">selected</eq> >每页显示10条</option>
                  <option value = "20" <eq name="limit" value="20">selected</eq> >每页显示20条</option>
                  <option value = "30" <eq name="limit" value="30">selected</eq> >每页显示30条</option>
                </select>
              </td>
            </tr>            
            <tr>
              <td class="footer pt10 pb10" colspan="2">
                <input type="submit" class="button mt10 mb10" value="提交" />
              </td>
            </tr>
          </tbody>
          </form>
        </table>


<table class="tableborder" width="100%">
<form id="userform" action="{:U('admin/User/doedit')}" method="POST">
				<tbody>
					<tr class="top">
						<td class="border" colspan="9"></td>
					</tr>
					<tr>
						<th class="header" colspan="9">标题</th>
					</tr>
					<tr>
					
						<td class="footer" colspan="9" style="text-align:left;color:blue;">
						一共有 <font color="red">{$count}</font> 用户
						</td>
					</tr>					
					<tr class="label">
						<th> 选择 <input type="checkbox" onclick="c.toggle(this)" class="checkbox"/></th>
						<th>用户ID</th>
						<th>头像</th>
						<th>用户名</th>
						<th>工号</th>
						<th>用户组</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
<volist id="vo" name="list">					
					<tr class="cell altbg1">
						<td style="text-align:center;"><input type="checkbox" class="checkbox" name="id[]" value="{$vo.uid}" /></td>
						<td>{$vo.uid}</td>
						<td class="pt10 pb10"> <a href="{:U('space/View/index',array('uid'=>$vo['uid']))}" target="_blank"><img src="{$vo.uid|getUserFace='small'}" style="height:60px;"/></a></td>
						<td><a href="{:U('space/View/index',array('uid'=>$vo['uid']))}" target="_blank">{$vo.fullname}</a></td>
						<td>{$vo.uname}</td>
						<td><php>$usergroups = (model('UserGroup')->getUserGroups($vo['uid'],true) )</php>
							<volist id="uvo" name="usergroups">
									{$uvo.gname}<br>
							</volist>
						</td>
						<td>&nbsp;</td>
						<td>
							<button type="button" onclick="c.edit({$vo.uid})">编辑</button>
							
						</td>
					</tr>
</volist>
					<tr>
					<td colspan="5">
                    <div style="float:left">全选<input type="checkbox" onclick="c.toggle(this)" class="checkbox"/>&nbsp;&nbsp;&nbsp;操作:<select name="type" style="margin-right:10px;" onchange="changeDoType(this);">
<!--						<option value="commend">推荐</option>
						<option value="uncommend">取消推荐</option>-->
                        <option></option>
						<option value="movegroup">转移到用户组</option>
						<option value="moveoutgroup">转出用户组</option>
				    </select><span name="grouplists" style="display:none;style="margin-right:10px;">用户组:<select  name="togroupId" >
				    <option value="0">普通用户组</option>
				    <volist id="vo" name="grouplist">
						<option value="{$vo.gid}">{$vo.gname}</option>
					</volist>
				    </select>
				    </span>
				    <input type="submit" class="button" value="提交">
						
					</div>
					
					</td>
						<td class="footer" colspan="4">
						<div class="page mt5 alR mb20" style="float:right;">
							{$pages}
						</div>
						</td>
					</tr>
					<tr class="bottom">
						<td class="border" colspan="6">&nbsp;</td>
					</tr>
				</tbody>
				</form>
			</table>        
		</div>
		<script type="text/javascript">

			function changeDoType(o){
				var obj= $("span[name=grouplists]");
				if($(o).val()=='movegroup' || $(o).val()=='moveoutgroup'){
					obj.show();
				}else{
					obj.hide();
				}
			}
			c = new ctrl('id[]');
		</script>
	</body>
</html>
